﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication6
{
    public partial class form_Fibonaci : Form
    {
        private RecursiveFibonaci rf_fibonaci;
        private Dynamicfibonaci dm_fibonaci;


        /// <summary>
        /// Constructor of form_Fibonaci class
        /// </summary>
        public form_Fibonaci()
        {
            InitializeComponent();
        }
        

        /// <summary>
        /// Enter Key Press Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tb_n_KeyDown(object sender, KeyEventArgs e)
        {            
            if (e.KeyCode == Keys.Enter)
            {
                this.Cursor = Cursors.WaitCursor;//set current cursor to waitting posititon when processing

                int n = Int16.Parse(this.tb_n.Text);//Get n from textbox

                dm_fibonaci = new Dynamicfibonaci(n);
                dm_fibonaci.Implement();
                this.lb_dynamictimes.Text = dm_fibonaci.getElapsetimes().ToString();
                this.f_dinamic.Text = dm_fibonaci.getFibonaci().ToString();
                //
                //
                rf_fibonaci = new RecursiveFibonaci(n);
                rf_fibonaci.Implement();
                this.lb_recursivetimes.Text = rf_fibonaci.GetElapseTime().ToString();
                this.f_recursive.Text = rf_fibonaci.Get_Fibonaci().ToString();

                this.Cursor = Cursors.Default;//return the default cursor position
            }           
        }


        /// <summary>
        /// Exit button Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_thoat_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }


    }
}
